<html>
<head>
  <title>CGU - Digest - Tests</title>
  <style type="text/css">
    pre {
      font-size: 8pt;
    }
  </style>
</head>
<body>

<script type="text/javascript">
function println() {
  for (var i = 0; i < arguments.length; i += 1)
    document.write(arguments[i]);
  document.write('&nbsp;<br />');
}
</script>

<script type="text/javascript" src="../lib/cgu.digest.js"></script>
<script type="text/javascript">
document.write('<pre>');

var md6_one_block = '', md6_two_block = '', md6_two_block_L0 = '';

for (var i = 0; i < 57; i += 1)
  md6_one_block += '\x11\x22\x33\x44\x55\x66\x77';
md6_one_block += '\x11';

md6_two_block += md6_one_block;
for (var i = 0; i < 57; i += 1)
  md6_two_block += '\x22\x33\x44\x55\x66\x77\x11';
md6_two_block += '\x22';

md6_two_block_L0 = md6_two_block.substr(0, (8 * 75));

var timeStart = new Date().getTime();

println('= Build Check =');
println();
println('CGU Build: ', !!window.CGU);
println('Version: ', CGU.Version);
println();
println('= Encodings =');
println();
println(CGU.Sequence('AB').str());
println(CGU.Sequence('AB').hex());
println(CGU.Sequence('AB').base32());
println(CGU.Sequence('AB').base64());
println();
println('= Hashes =');
println();
println('All:   ', CGU.hashes().join(', '));
println('HMAC:  ', CGU.hashes(false).join(', '));
println('Keyed: ', CGU.hashes(true).join(', '));
println();
println('= UTF-8 Encode =');
println();
println('U+0024  U+00A2  U+20AC');
println('    24    C2A2  E282AC');
println('    ',
  CGU.Sequence(CGU.utf8Encode('\u0024')).base16(), '    ',
  CGU.Sequence(CGU.utf8Encode('\u00A2')).base16(), '  ',
  CGU.Sequence(CGU.utf8Encode('\u20AC')).base16()
);
println();
println(CGU.Sequence(CGU.utf8Encode('\u0024\u00A2\u20AC')).base16());
println();
println('= MD =');
println();
println('a448017aaf21d8525fc10ae87aa6729d');
println(CGU.hash('md4', 'abc'));
println();
println('900150983cd24fb0d6963f7d28e17f72');
println(CGU.hash('md5', 'abc'));
println();
println('9294727a3638bb1c13f48ef8158bfc9d');
println(CGU.hmac('md5', 'Hi There', '\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b'));
println();
println('= SHA =');
println();
println('A9993E364706816ABA3E25717850C26C9CD0D89D'.toLowerCase());
println(CGU.hash('sha1', 'abc'));
println();
println('23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7E36C9DA7'.toLowerCase());
println(CGU.hash('sha224', 'abc'));
println();
println('BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD'.toLowerCase());
println(CGU.hash('sha256', 'abc'));
println();
println('CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7'.toLowerCase());
println(CGU.hash('sha384', 'abc'));
println();
println('DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F'.toLowerCase());
println(CGU.hash('sha512', 'abc'));
println();
println('b617318655057264e28bc0b6fb378c8ef146be00');
println(CGU.hmac('sha1', 'Hi There', '\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b'));
println();
println('896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22');
println(CGU.hmac('sha224', 'Hi There', '\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b'));
println();
println('b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7');
println(CGU.hmac('sha256', 'Hi There', '\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b'));
println();
println('afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6');
println(CGU.hmac('sha384', 'Hi There', '\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b'));
println();
println('87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854');
println(CGU.hmac('sha512', 'Hi There', '\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b'));
println();
println('= RIPEMD =');
println();
println('c14a12199c66e4ba84636b0f69144c77');
println(CGU.hash('ripemd128', 'abc'));
println();
println('8eb208f7e05d987a9b044a8e98c6b087f15a0bfc');
println(CGU.hash('ripemd160', 'abc'));
println();
println('ad9db2c1e22af9ab5ca9dbe5a86f67dc');
println(CGU.hmac('ripemd128', '', '\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff'));
println();
println('cf387677bfda8483e63b57e06c3b5ecd8b7fc055');
println(CGU.hmac('ripemd160', '', '\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff\x01\x23\x45\x67'));
println();
println('= MD6 -- SHA-3 Candidate =');
println();
println('7538e7552a2e9cc94be251f73ce9cf67d4739b4b3f114e483ea38ab0');
println(CGU.hash('md6-224', md6_one_block).hex());
println();
println('fb75daf08d970c19f49b34ec768fea1a74583a5b1d1df2149a61cb36e120d197');
println(CGU.hash('md6-256', md6_one_block, '111222333').hex());
println();
println('614cec06b9a0332f8c14d7d4f29934e4f39b91046c1c2cd1fa9f84fc3ed2e89efb583003b2fc9e996cb690a8be68dbf2');
println(CGU.hash('md6-384', md6_two_block).hex());
println();
println('48e8dbfee51e36b0c549925ed9740df0d4e0aa9d46c5ec5bd7749a8c023b91582bb3fa07b311a4d3e774ebf5b5beffe806eea425c37af320ef06ff241bcb32e4');
println(CGU.hash('md6-512', md6_two_block, '111222333').hex());
println();
println('b81b7d4d84c3df8104b447445e6d87693f62fe91380b01ecc4bb0af4');
println(CGU.hash('md6-224-L0', md6_one_block).hex());
println();
println('e9eaf4c30140a4e7649a34b6d4976a930bf5681ea8a7e1a2471a1035d8eebb95');
println(CGU.hash('md6-256-L0', md6_two_block_L0).hex());
println();
println('de4f6f3715d87cefbb339eeae677a8594c7949a61ecf694dc12fd3243b42517a356b60837a2bffbd39a18401cb74db02');
println(CGU.hash('md6-384-L0', md6_one_block).hex());
println();
println('753c2fd701db4a9d4244ffd7e873858c10b9820193ac7e34202b3c94ca8b809e8fca74cd7eb46eebbd15a204bd236113c700a71cb582e06fab3fa321ad2cffcd');
println(CGU.hash('md6-512-L0', md6_two_block_L0).hex());
println();
println();

println(new Date().getTime() - timeStart, 'ms');

document.write('</pre>');
</script>

</body>
</html>
